package priv.pront.code.mati.province;

import java.util.*;

public class MC0207 {

    static int n, m;
    static Map<Integer, List<Integer>> map = new HashMap<>();
    static boolean flag = false;
    static boolean[] st;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        m = scanner.nextInt();
        st = new boolean[n + 1];
        for (int i = 0; i <= n; i++) {
            map.put(i, new ArrayList<>());
        }
        for (int i = 0; i < m; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            map.get(a).add(b);
        }
        List<Integer> integers = map.get(1);
        st[1] = true;
        for (Integer integer : integers) {
            if(!st[integer]) {
                st[integer] = true;
                dfs(integer);
            }
        }
        System.out.println(flag ? "Yes" : "No");
    }

    private static void dfs(int i) {
        if (i == n) {
            flag = true;
            return;
        }
        List<Integer> integers = map.get(i);
        for (int integer : integers) {
            if(st[integer]) continue;
            st[integer] = true;
            dfs(integer);
        }
    }

}
